React Color Alpha
Install
npm i @uiw/react-color-alpha
Usage
import Alpha from '@uiw/react-color-alpha';
function Demo() {
const [hsva, setHsva] = useState({ h: 0, s: 0, v: 68, a: 1 });
return (
<Alpha
hsva={hsva}
onChange={(newAlpha) => {
setHsva({ ...hsva, ...newAlpha });
}}
/>
);
}
Props
import { HsvaColor } from '@uiw/color-convert';
interface AlphaProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {
prefixCls?: string;
width?: number;
height?: number;
hsva: HsvaColor;
pointer?: ({ prefixCls, left }: PointerProps) => JSX.Element;
radius?: number;
background?: string;
direction?: 'vertical' | 'horizontal';
onChange?: (newAlpha: { a: number }, offset: Interaction) => void;
}
interface PointerProps extends React.HTMLAttributes<HTMLDivElement> {
prefixCls?: string;
left?: string;
top?: string;
}
License
Licensed under the MIT License.